package com.ruoyi.project.loan.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.loan.domain.RepaymentPlan;
import com.ruoyi.project.loan.mapper.RepaymentPlanMapper;
import com.ruoyi.project.loan.service.IRepaymentPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 还款计划Service业务层处理
 *
 * @author ruoyi
 * @date 2025-11-11
 */
@Service
public class RepaymentPlanServiceImpl implements IRepaymentPlanService {
    @Autowired
    private RepaymentPlanMapper repaymentPlanMapper;

    /**
     * 查询还款计划
     *
     * @param planId 还款计划主键
     * @return 还款计划
     */
    @Override
    public RepaymentPlan selectRepaymentPlanByPlanId(Long planId) {
        return repaymentPlanMapper.selectRepaymentPlanByPlanId(planId);
    }

    /**
     * 查询还款计划列表
     *
     * @param repaymentPlan 还款计划
     * @return 还款计划
     */
    @Override
    public List<RepaymentPlan> selectRepaymentPlanList(RepaymentPlan repaymentPlan) {
        return repaymentPlanMapper.selectRepaymentPlanList(repaymentPlan);
    }

    /**
     * 新增还款计划
     *
     * @param repaymentPlan 还款计划
     * @return 结果
     */
    @Override
    public int insertRepaymentPlan(RepaymentPlan repaymentPlan) {
        repaymentPlan.setCreateTime(DateUtils.getNowDate());
        return repaymentPlanMapper.insertRepaymentPlan(repaymentPlan);
    }

    /**
     * 修改还款计划
     *
     * @param repaymentPlan 还款计划
     * @return 结果
     */
    @Override
    public int updateRepaymentPlan(RepaymentPlan repaymentPlan) {
        repaymentPlan.setUpdateTime(DateUtils.getNowDate());
        return repaymentPlanMapper.updateRepaymentPlan(repaymentPlan);
    }

    /**
     * 批量删除还款计划
     *
     * @param planIds 需要删除的还款计划主键
     * @return 结果
     */
    @Override
    public int deleteRepaymentPlanByPlanIds(Long[] planIds) {
        return repaymentPlanMapper.deleteRepaymentPlanByPlanIds(planIds);
    }

    /**
     * 删除还款计划信息
     *
     * @param planId 还款计划主键
     * @return 结果
     */
    @Override
    public int deleteRepaymentPlanByPlanId(Long planId) {
        return repaymentPlanMapper.deleteRepaymentPlanByPlanId(planId);
    }
}
